﻿using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.ApplicationServices;
using ZhuXingFamilys.User;
namespace ZhuXingFamilys
{
    public class ButtonAvailabilityClass : IExternalCommandAvailability, IExternalEventHandler
    {


        public void Execute(UIApplication app)
        {
            //UIApplication uiApp = commandData.Application;
            //Document doc = app.ActiveUIDocument.Document;
            //Transaction ts = new Transaction(doc, "查询按钮可用性");
            //ts.Start();

            RibbonPanel ribbonPanel = null;
            List<RibbonPanel> listPanel = app.GetRibbonPanels("筑星族库");
            foreach (RibbonPanel panel in listPanel)
            {
                if (panel.Name == "云族库")//RibbonPanel的Name
                {
                    ribbonPanel = panel;
                    break;
                }
            }
            //间距
            TextBox textBox = null;
            IList<RibbonItem> listItem = ribbonPanel.GetItems();
            foreach (RibbonItem item in listItem)
            {
                if (item.Name == "pbdSelect")//Ribbon的Name属性
                {
                    textBox = item as TextBox;
                    textBox.Enabled = true;
                }
            }

            //ts.Commit();

        }

        public string GetName()
        {
            return "ButtonAvailabilityClass";
        }

        public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
        {
            return UserLoginCommand.TestZKLogincommand();
        }
    }
}
